/**
 * Description: RegisterLateServiceImpl.java
 * Copyright (c) 2008-2009  Neo. 
 * All Rights Reserved.
 * @version 1.0  Apr 4, 2009 1:26:18 PM 李萌（neolimeng@gmail.com）created
 */
package org.paradise.dms.services.impl;

import java.util.List;

import org.apache.log4j.Logger;
import org.paradise.dms.dao.impl.RegisterLateDAOImpl;
import org.paradise.dms.pojo.RegisterLate;
import org.paradise.dms.services.RegisterLateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

/**
 * Description: Copyright (c) 2008-2009 Neo. All Rights Reserved.
 * 
 * @version 1.0 Apr 4, 2009 1:26:18 PM 李萌（neolimeng@gmail.com）created
 */
@Service
public class RegisterLateServiceImpl implements RegisterLateService {
	private static Logger log = Logger.getLogger(RegisterLateServiceImpl.class);
	@Autowired
	@Qualifier("registerLateDAOImpl")
	private RegisterLateDAOImpl registerLateDAOImpl;
	List<RegisterLate> lrl;
	RegisterLate rl;

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.paradise.dms.services.RegisterLateService#deleteRegisterLate(int)
	 */
	public boolean deleteRegisterLate(int rlid) {
		try {
			this.registerLateDAOImpl.deleteRegisterLate(rlid);
			log.info("DMS_info_删除晚归记录，成功！！ID为：" + rlid);
			return true;
		} catch (Exception e) {
			log.error("DMS_error_删除晚归记录，失败！！ID为：" + rlid);
			e.printStackTrace();
			return false;
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.paradise.dms.services.RegisterLateService#getAllRegisterLate()
	 */
	public List<RegisterLate> getAllRegisterLate() {
		try {
			lrl = this.registerLateDAOImpl.getAllRegisterLate();
			log.info("DMS_info_取得所有晚归记录，成功！！共有" + lrl.size() + "条信息。");
			return lrl;
		} catch (Exception e) {
			log.error("DMS_error_取得所有晚归记录，失败！！");
			e.printStackTrace();
			return null;
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.paradise.dms.services.RegisterLateService#getRegisterLate(int)
	 */
	public RegisterLate getRegisterLate(int rlid) {
		try {
			rl = this.registerLateDAOImpl.getRegisterLate(rlid);
			log.info("DMS_info_根据晚归登记记录ID取得晚归登记记录，成功！！ID为：" + rlid);
			return rl;
		} catch (Exception e) {
			log.error("DMS_error_根据晚归登记记录ID取得晚归登记记录，失败！！ID为：" + rlid);
			e.printStackTrace();
			return null;
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.paradise.dms.services.RegisterLateService#insertRegisterLate(org.paradise.dms.pojo.RegisterLate)
	 */
	public boolean insertRegisterLate(RegisterLate rl) {
		try {
			this.registerLateDAOImpl.insertRegisterLate(rl);
			log.info("DMS_info_插入晚归记录，成功！！学号：" + rl.getRegisterlatestudentno());
			return true;
		} catch (Exception e) {
			log.error("DMS_error__插入晚归记录，失败！！学号："
					+ rl.getRegisterlatestudentno());
			e.printStackTrace();
			return false;
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.paradise.dms.services.RegisterLateService#updateRegisterLate(org.paradise.dms.pojo.RegisterLate)
	 */
	public boolean updateRegisterLate(RegisterLate rl) {
		try {
			this.registerLateDAOImpl.updateRegisterLate(rl);
			log.info("DMS_info_更新晚归记录，成功！！ID 为" + rl.getRegisterlateid());
			return true;

		} catch (Exception e) {
			log.error("DMS_error_更新晚归记录，失败！！ID 为" + rl.getRegisterlateid());
			e.printStackTrace();
			return false;
		}
	}

	public int getAllRows() {
		return this.registerLateDAOImpl.getAllRows();
	}

	public List<RegisterLate> listAllRows(int pageSize, int startRow) {
		try {
			lrl = this.registerLateDAOImpl.listAllRegisterLate(pageSize,
					startRow);
			log.info("DMS_info_分页取得所有晚归登记，成功！！本次读取" + pageSize + "条，起始条为第"
					+ startRow + "条");
			return lrl;
		} catch (Exception e) {
			log.error("DMS_error_分页取得所有晚归登记，失败！!");
			e.printStackTrace();
			return null;
		}

	}

	/**
	 * @return the registerLateDAOImpl
	 */
	public RegisterLateDAOImpl getRegisterLateDAOImpl() {
		return registerLateDAOImpl;
	}

	/**
	 * @param registerLateDAOImpl
	 *            the registerLateDAOImpl to set
	 */
	public void setRegisterLateDAOImpl(RegisterLateDAOImpl registerLateDAOImpl) {
		this.registerLateDAOImpl = registerLateDAOImpl;
	}

	public List<RegisterLate> getLrl() {
		return lrl;
	}

	public void setLrl(List<RegisterLate> lrl) {
		this.lrl = lrl;
	}

	public RegisterLate getRl() {
		return rl;
	}

	public void setRl(RegisterLate rl) {
		this.rl = rl;
	}

}
